<!doctype html>
<html lang="en">
<head>
    @include('wap.layout.head')
    <link rel="stylesheet" href="{{asset('/css/wap/marking_message.css')}}">
    <link href="{{asset('/frame/animate.css')}}" rel="stylesheet" />
    <link rel="stylesheet" href="{{asset('/js/wap/dist/dropload.css')}}">
    <script src="{{asset('/js/wap/dist/dropload.min.js')}}"></script>
</head>
<body>
	<div class="news">
		<ul>
			<li class="buy_message buy_nw">求购信息</li>
			<li class="buy_message sale_nw">甩货信息</li>
			<li class="buy_message follow_nw">关注信息</li>
		</ul>
		<div class="buy content" id="B1" style="display: block;">
			<div class="want_buy">
				<!-- <div class="store_news">
					<h3 class="store_num">编号：QG123456789321255</h3>
					<h4 class="store_tit">美高姆N7106G网络16路硬盘录像机</h4>
					<span>摄像机</span><span>海康威视</span><span>浙江杭州发货</span>
					<p class="store_day">2017-09-28 15:25:34 <span>521458</span><i>3天前</i></p>
					<a href="javascript:;" data-id="1" class="delete">删除</a>
					<a href="javascript:;" class="again">重发</a>
				</div> -->
			</div>
		</div>
		<div class="sale content" id="B1" style="display: none;">
			<div class="dumped_goods">
				<!-- <div class="store_news">
					<h3 class="store_num">编号：QG123456789321255</h3>
					<div class="store_prc">
						<p class="img_box">
							<img class="store_img" src="{{asset('/img/wap/news/pic.jpg')}}" alt="">
						</p>
						<p class="img_box">
							<img class="store_img" src="{{asset('/img/wap/news/pic.jpg')}}" alt="">
						</p>
						<p class="img_box">
							
						</p>
					</div>
					<h4 class="store_tit">15年的DS-7808N-E2 200卖 包邮 <br>白菜价甩卖</h4>
					<span class="new">￥298</span><span class="old">原价:<i>380</i></span>
					<p class="store_day">2017-09-28 15:25:34</p>
					<div class="btn">
						<a href="javascript:;" data-id="4" class="delete">删除</a>
						<a href="javascript:;" class="again">重发</a>
					</div>
				</div> -->
			</div>
		</div>
		<div class="follow content" id="B1" style="display: none;">
			<div class="follow_message">
				<!-- <div class="store_news">
					<h3 class="store_num">编号：QG123456789321255</h3>
					<h4 class="store_tit">美高姆N7106G网络16路硬盘录像机</h4>
					<span>摄像机</span><span>海康威视</span><span>浙江杭州发货</span>
					<p class="store_day">2017-09-28 15:25:34 <span>521458</span><i>3天前</i></p>
					<a href="" class="look">查看</a>
				</div> -->
				<!-- <div class="store_new">
					<h3 class="store_num">编号：QG123456789321255</h3>
					<div class="store_prc">
						<p class="img_box">
							<img class="store_img" src="{{asset('/img/wap/news/pic.jpg')}}" alt="">
						</p>
						<p class="img_box">
							<img class="store_img" src="{{asset('/img/wap/news/pic.jpg')}}" alt="">
						</p>
						<p class="img_box">
							
						</p>
					</div>
					<h4 class="store_tit">15年的DS-7808N-E2 200卖 包邮 <br>白菜价甩卖</h4>
					<span class="new">￥298</span><span class="old">原价:<i>380</i></span>
					<p class="store_day">2017-09-28 15:25:34</p>
					<div class="btn">
						<a href="javascript:;" data-id="4" class="delete">删除</a>
						<a href="javascript:;" class="again">重发</a>
					</div>
				</div> -->
			</div>
		</div>
	</div>
<script type="text/javascript">
    $(function(){
    	$("ul li").click(function(){
	        $(".news")
	        .children("#B1").eq($(this).index())
	        .show()
	        .siblings("#B1")
	        .hide()
    	})
	    $("ul li")
	    .on("click",function(){
	        $(this)
	        .css({"background":"#0b4e7e"})
	        .siblings()
	        .css({"background":"#0076c7"})
	    })

     //dropload
      var page = 0;// 页数
      var size = 5;// 每页展示5个
      var itemIndex = 0; 
      var tab1LoadEnd = false; 
      var tab2LoadEnd = false;
      var tab3LoadEnd = false;
      $("ul li").click(function(){
      	var $this = $(this);
      	itemIndex = $this.index();
      	// console.log(itemIndex) 
      	// 如果选中菜单一 
          if(itemIndex == '0'){ 
              // 如果数据没有加载完 
              if(!tab1LoadEnd){ 
                  // 解锁 
                  drop_load.unlock(); 
                  drop_load.noData(false); 
              }else{ 
                  // 锁定 
                  drop_load.lock('down'); 
                  drop_load.noData(); 
              } 
          // 如果选中菜单二 
          }else if(itemIndex == '1'){ 
              if(!tab2LoadEnd){ 
                  // 解锁 
                  drop_load.unlock(); 
                  drop_load.noData(false); 
              }else{ 
                  // 锁定 
                  drop_load.lock('down'); 
                  drop_load.noData(); 
              } 
              // 如果选中菜单三 
          }else if(itemIndex == '2'){ 
              if(!tab3LoadEnd){ 
                  // 解锁 
                  drop_load.unlock(); 
                  drop_load.noData(false); 
              }else{ 
                  // 锁定 
                  drop_load.lock('down'); 
                  drop_load.noData(); 
              } 
          } 
          // 重置 
          drop_load.resetload(); 
      })
      // var counter = 0; 
      // 每页展示5个 
      // var page = 0; 
      // var pageStart = 0,pageEnd = 0;
      var  drop_load = $('.content').dropload({
            scrollArea : window,
            loadDownFn : function(me){
                // 拼接HTML
                if(itemIndex == '0'){
	                $.ajax({
	                    type: 'GET',
	                    url: 'http://ons.me/tools/dropload/json.php?page='+page+'&size='+size,
	                    dataType: 'json',
	                    success: function(data){
	                    	var result = '';
	                    	page++;
	                        var arrLen = data.length;
	                        if(arrLen > 0){
	                            for(var i=0; i<arrLen; i++){
	                                result +=   '<div class="store_news">'+
													'<h3 class="store_num">编号：QG123456789321255</h3>'+
													'<h4 class="store_tit">美高姆N7106G网络16路硬盘录像机</h4>'+
													'<span>摄像机</span><span>海康威视</span><span>浙江杭州发货</span>'+
													'<p class="store_day">2017-09-28 15:25:34 <span>521458</span><i>3天前</i></p>'+
													'<a href="javascript:;" data-id="1" class="delete">删除</a>'+
													'<a href="javascript:;" class="again">重发</a>'+
												'</div>';
	                            }
	                        // 如果没有数据
	                        }else{
	                            // 锁定
	                            me.lock();
	                            // 无数据
	                            me.noData();
	                        }
	                        // 为了测试，延迟1秒加载
	                        setTimeout(function(){
	                            // 插入数据到页面，放到最后面
	                            $('.want_buy').append(result);
	                            
	                            // 每次数据插入，必须重置
	                            me.resetload();
	                        },1000);
	                    },
	                    error: function(xhr, type){
	                        //alert('Ajax error!');
	                        // 即使加载出错，也得重置
	                        me.resetload();
	                    }
	                });
	                // 加载菜单二的数据 
                 }else if(itemIndex == '1'){
	                 	$.ajax({ 
	                      type: 'GET', 
	                      url: 'http://ons.me/tools/dropload/json.php?page='+page+'&size='+size, 
	                      dataType: 'json', 
	                      success: function(data){ 
	                          var result = ''; 
	                          page++;
	                          var arrLen = data.length;
	                          for(var i=0; i<arrLen; i++){
	                                result +=   '<div class="store_news">'+
													'<h3 class="store_num">编号：QG123456789321255</h3>'+
													'<div class="store_prc">'+
														'<p class="img_box">'+
															'<img class="store_img" src="http://www.ejing365.com/img/inc/header/ejinglogo.png" alt="">'+
														'</p>'+
														'<p class="img_box">'+
															'<img class="store_img" src="http://www.ejing365.com/img/inc/header/ejinglogo.png" alt="">'+
														'</p>'+
														'<p class="img_box">'+
															
														'</p>'+
													'</div>'+
													'<h4 class="store_tit">15年的DS-7808N-E2 200卖 包邮 <br>白菜价甩卖</h4>'+
													'<span class="new">￥298</span><span class="old">原价:<i>380</i></span>'+
													'<p class="store_day">2017-09-28 15:25:34</p>'+
													'<div class="btn">'+
														'<a href="javascript:;" data-id="4" class="delete">删除</a>'+
														'<a href="javascript:;" class="again">重发</a>'+
													'</div>'+
												'</div>';
	                            } 
	                          // 为了测试，延迟1秒加载 
	                          setTimeout(function(){ 
	                              $('.dumped_goods').append(result);
	                              // 每次数据加载完，必须重置 
	                              imgHeight();
	                              me.resetload(); 
	                          },100); 
	                      }, 
	                      error: function(xhr, type){ 
	                          // alert('Ajax error!'); 
	                          // 即使加载出错，也得重置 
	                          me.resetload(); 
	                      } 
	                  }); 
                 }else if(itemIndex == '2'){
                 	$.ajax({ 
	                      type: 'GET', 
	                      url: 'http://ons.me/tools/dropload/json.php?page='+page+'&size='+size, 
	                      dataType: 'json', 
	                      success: function(data){ 
	                          var result = '';
	                          page++;
	                          var arrLen = data.length; 
	                          for(var i=0; i<arrLen; i++){
	                                result +=   '<div class="store_news">'+
													'<h3 class="store_num">编号：QG123456789321255</h3>'+
													'<h4 class="store_tit">美高姆N7106G网络16路硬盘录像机</h4>'+
													'<span>摄像机</span><span>海康威视</span><span>浙江杭州发货</span>'+
													'<p class="store_day">2017-09-28 15:25:34 <span>521458</span><i>3天前</i></p>'+
													'<a href="" class="look">查看</a>'+
												'</div>'+
												'<div class="store_new">'+
													'<h3 class="store_num">编号：QG123456789321255</h3>'+
													'<div class="store_prc">'+
														'<p class="img_box">'+
															'<img class="store_img" src="/img/wap/news/pic.jpg" alt="">'+
														'</p>'+
														'<p class="img_box">'+
															'<img class="store_img" src="/img/wap/news/pic.jpg" alt="">'+
														'</p>'+
														'<p class="img_box">'+
															
														'</p>'+
													'</div>'+
													'<h4 class="store_tit">15年的DS-7808N-E2 200卖 包邮 <br>白菜价甩卖</h4>'+
													'<span class="new">￥298</span><span class="old">原价:<i>380</i></span>'+
													'<p class="store_day">2017-09-28 15:25:34</p>'+
													'<div class="btn">'+
														'<a href="javascript:;" class="look">查看</a>'+
													'</div>'+
												'</div>';
	                            } 
	                          // 为了测试，延迟1秒加载 
	                          setTimeout(function(){ 
	                          	$('.follow_message').append(result);
	                              // 每次数据加载完，必须重置 
	                              imgHeight();
	                              me.resetload(); 
	                          },100); 
	                      }, 
	                      error: function(xhr, type){ 
	                          // alert('Ajax error!'); 
	                          // 即使加载出错，也得重置 
	                          me.resetload(); 
	                      } 
	                  }); 
                 }
            }
        });
        function getlist(){
            page = 0;
            $(".content").html('');
            drop_load.resetload();
        }
       
    });
    $(window).resize(function () {
        imgHeight();
    })
    function imgHeight(){
        $('.store_prc .img_box').height($('body').width()*0.98*0.32);
        $('.store_prc .img_box').css({'line-height':$('body').width()*0.98*0.32+'px'});
    }
    //删除
   $(document).on("click",".delete",function(){
   		   var id = $(this).attr('data-id');
          layer.open({
          	  content: '您确定要删除吗？',
              btn: ['确定', '取消'] //可以无限个按钮
          }, function (index) {
              $.ajax({
                  url: "",
                  type: 'delete',
                  dataType: 'json',
                  data: {'id': id},
                  success: function (data) {
                      if (0 == data.code) {
                          layer.alert("删除成功", {
                              icon: 1
                          }, function () {
                              location.reload();
                          });
                      } else {
                          layer.alert(data.message, {
                              icon: 2
                          });
                      }
                  }
              });
          }, function (index, layero) {
              layer.close(index);
          });
   })
</script>
</body>
</html>